﻿<%@ Page Title="Thêm khối lượng" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="KhoiLuongNew.aspx.cs" Inherits="QuanLyHopDong.Web.HopDong.KhoiLuongNew" %>

<%@ Import Namespace="Resources" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%=GlobalStrings.AddNew %> Khối lượng</h2>
    <p></p>
    <span class="failureNotification">
        <asp:Literal ID="lblErrorMessage" runat="server"></asp:Literal></span>
    <div>
        <table>
            <tr>
                <td>
                    <b>Số HĐ:</b>
                    <asp:Literal ID="ltrSoHopDong" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Đơn vị ký HĐ:</b>
                    <asp:Literal ID="ltrTenDonVi" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    <b>Loại dự án:</b>
                    <asp:Literal ID="ltrLoaiDuAn" runat="server"></asp:Literal>
                </td>
            </tr>
        </table>
    </div>
    <div>
        <table>
            <tr>
                <td style="vertical-align: top;">
                    <div style="margin-right: 50px; vertical-align: top;">
                        <p>
                            <label>Mã tuyến:</label>
                            <asp:TextBox ID="txtMaTuyen" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Điểm đầu:</label>
                            <asp:TextBox ID="txtDiemDau" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Điểm cuối:</label>
                            <asp:TextBox ID="txtDiemCuoi" runat="server" CssClass="textEntry name validate[required]"></asp:TextBox>
                        </p>
                        <p>
                            <label>Chiều dài tuyến (m):</label>
                            <asp:TextBox ID="txtChieuDaiTuyen" runat="server"></asp:TextBox>
                        </p>
                        <p>
                            <label>Loại cáp:</label>
                            <asp:TextBox ID="txtLoaiCap" runat="server"></asp:TextBox>
                        </p>
                    </div>
                </td>
                <td style="vertical-align: top;">
                    <div style="vertical-align: top;">
                        <p>
                            <label>Đội thi công</label>
                            <asp:DropDownList ID="ddlDoiThiCong" runat="server"></asp:DropDownList>
                        </p>
                        <p>
                            <label>Tiến độ thi công:</label>
                            <asp:DropDownList ID="ddlTienDo" runat="server">
                                <asp:ListItem Value="1">Chưa thi công</asp:ListItem>
                                <asp:ListItem Value="2">Đang thi công</asp:ListItem>
                                <asp:ListItem Value="3">Thi công xong</asp:ListItem>
                            </asp:DropDownList>
                        </p>
                        <p>
                            <label>Nhận vật tư A:</label>
                            <asp:DropDownList ID="ddlNhanVatTuA" runat="server">
                                <asp:ListItem Value="1">Chưa nhận vật tư</asp:ListItem>
                                <asp:ListItem Value="2">Đã nhận vật tư</asp:ListItem>
                            </asp:DropDownList>
                        </p>
                        <p>
                            <label>Ghi chú:</label>
                            <asp:TextBox ID="txtNote" TextMode="MultiLine" runat="server" CssClass="textEntry description"></asp:TextBox>
                        </p>
                    </div>
                </td>
            </tr>
        </table>
    </div>

    <div>
        <p>
            <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:GlobalStrings, Save %>"
                CssClass="submitButton" OnClick="btnSave_Click" />
            <input id="btnCancel" type="button" value="<%=GlobalStrings.Cancel %>"
                class="submitButton" onclick="Cancel()" />
        </p>
    </div>

    <script type="text/javascript">
        $(function() {
            $(theForm).validationEngine();

            $("#<%=txtDiemDau.ClientID %>").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "/DanhMuc/DiaDiem/Default.aspx/SearchDiaDiem",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function(data) {
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
            
            $("#<%=txtDiemCuoi.ClientID %>").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "/DanhMuc/DiaDiem/Default.aspx/SearchDiaDiem",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function(data) {
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
            
            $("#<%=txtLoaiCap.ClientID %>").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "/DanhMuc/LoaiCap/Default.aspx/SearchLoaiCap",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            term: extractLast(request.term)
                        }),
                        success: function(data) {
                            response($.map(data.d, function(item) {
                                return {
                                    label: item.value,
                                    value: item.value
                                };
                            }));
                        }
                    });
                }
            });
        });

        function split(val) {
            return val.split(/,\s*/);
        }

        function extractLast(term) {
            return split(term).pop();
        }

        function Cancel() {
            window.location = 'KhoiLuong.aspx?hopDongId=<%=Request.Params["hopDongId"] %>';
        }
    </script>
</asp:Content>
